-- 操纵时宜
local chaozhonshiyi = fk.CreateSkill {
    name = "mcdh_chaozhonshiyi",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

chaozhonshiyi:addEffect(fk.CardUsing,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        local logic = room.logic
        local useEvent = logic:getCurrentEvent()
        return player:hasSkill(self.name) and not lib.IsUsingPubliccard(useEvent) and data:IsUsingHandcard(target) and data.card.trueName == "slash"
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        data.nullifiedTargets = player.room.players
        if table.every(data.card:isVirtual() and data.card.subcards or {data.card.id}, function(id) return room:getCardArea(id) == Card.Processing end) then
            room:obtainCard(target, data.card, true, fk.ReasonJustMove)
            for _, id in ipairs(data.card:isVirtual() and data.card.subcards or {data.card.id}) do
                local card = Fk:getCardById(id)
                room:setCardMark(card,"@@mcdh_overt_card" , 1)
            end
        end
        if data.from ~= player then
            lib.LoadAmmo(player,player,1,self.name)
        else
            if not data.extraUse then
                target:addCardUseHistory(data.card.trueName, -1)
                data.extraUse = true
            end
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_chaozhonshiyi"] = "操纵时宜",
    [":mcdh_chaozhonshiyi"] = "当一名角色使用暗置的【杀】时，你可以令此【杀】无效，然后其获得此【杀】并明置，若使用者为你，此【杀】不计入次数；不为你，你装填一枚弹药.",
}

return chaozhonshiyi